package ojchannel

import "sync"

/*
OJ Channel
*/

type LogINFO struct {
	Level   int
	Message string
}

type OJChannel struct {
	C    chan LogINFO
	once sync.Once
}

func NewChannel() *OJChannel {
	return &OJChannel{C: make(chan LogINFO)}
}

func (this *OJChannel) SafeClose() {
	this.once.Do(func() {
		close(this.C)
	})
}

func FastLog(level int, msg string) LogINFO {
	var log LogINFO
	log.Level = level
	log.Message = msg
	return log
}
